package com.sc.nft.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sc.nft.entity.UserInfo;
import com.sc.nft.entity.WantBuyOrder;
import com.sc.nft.entity.dto.WantBuyOrderCreateDTO;
import com.sc.nft.entity.dto.WantBuyOrderSellDTO;
import com.sc.nft.entity.vo.*;
import com.sc.nft.enums.SecondWantBuyOrderStatusEnum;
import com.sc.nft.enums.SecondWantBuyOrderTypeEnum;

import java.util.Date;
import java.util.List;

/**
 * @author 刘国航
 * @desc
 * @since 2024/12/19 20:04
 */
public interface WantBuyOrderService {

    /**
     * 分页查询
     *
     * @param page
     * @param userTel
     * @param status
     * @return
     */
    IPage<WantBuyOrderVO> page(Page page, String userTel, SecondWantBuyOrderStatusEnum status);

    /**
     * 求购单成交记录
     *
     * @param page
     * @param id
     * @param sellUserTel
     * @param startCreateTime
     * @param endCreateTime
     * @param startPayTime
     * @param endPayTime
     * @return
     */
    IPage<WantBuyOrderAdminRecordVO> recordPage(Page page, Long id, String sellUserTel, Date startCreateTime, Date endCreateTime, Date startPayTime, Date endPayTime);

    /**
     * 是否开启求购
     *
     * @param orderType
     * @param relationId
     * @return
     */
    WantBuyOrderEnableVO enableWantBuy(SecondWantBuyOrderTypeEnum orderType, Long relationId);

    /**
     * 打开求购单创建页面
     *
     * @param orderType
     * @param relationId
     * @return
     */
    WantBuyOrderOpenCreateVO openCreate(UserInfo userInfo, SecondWantBuyOrderTypeEnum orderType, Long relationId);

    /**
     * 创建求购单
     *
     * @param dto
     */
    void create(UserInfo userInfo, WantBuyOrderCreateDTO dto, String ip);

    /**
     * 求购单列表分页查询
     *
     * @param page
     * @param orderType
     * @param relationId
     * @return
     */
    IPage<WantBuyOrderWebPageVO> page(UserInfo userInfo, Page page, SecondWantBuyOrderTypeEnum orderType, Long relationId);

    /**
     * 获取求购数量
     *
     * @param userInfo
     * @param id
     * @return
     */
    WantBuyOrderWebVO queryUsableWantBuyQuantity(UserInfo userInfo, Long id);

    /**
     * 获取本人拥有的藏品/道具
     *
     * @param userInfo
     * @param page
     * @param id
     * @return
     */
    IPage<WantBuyOrderQueryHoldVO> queryHoldPage(UserInfo userInfo, Page page, Long id);

    /**
     * 我的求购列表
     *
     * @param userInfo
     * @param page
     * @param orderType
     * @param relationId
     * @return
     */
    IPage<WantBuyOrderMyPageVO> myWantBuyPage(UserInfo userInfo, Page page, SecondWantBuyOrderTypeEnum orderType, Long relationId);

    /**
     * 我的求购详情
     *
     * @param id
     * @return
     */
    WantBuyOrderMyDetailVO myWantBuyDetail(Long id);

    /**
     * 我的求购单成交记录
     *
     * @param page
     * @param id
     * @return
     */
    IPage<WantBuyOrderRecordVO> myRecordPage(Page page, Long id);

    /**
     * 关闭求购单
     *
     * @param id
     */
    void close(Long id);

    /**
     * 查询最近5分钟待关闭的求购单
     *
     * @return
     */
    List<WantBuyOrder> queryReleasesFiveMinuteLater();

    /**
     * 出售
     *
     * @param userInfo
     * @param dto
     */
    void sell(UserInfo userInfo, WantBuyOrderSellDTO dto, String ip);

    /**
     * 计算收入
     *
     * @param id
     * @param size
     * @return
     */
    WantBuyOrderIncomeVO income(UserInfo userInfo, Long id, Integer size);

}
